#include<iostream>
#include<vector>
#include<string>

using namespace std;

// #define DEBUG_MOD
#ifdef DEBUG_MOD
#define LOG(str) std::cout << __LINE__ << ": " << str << endl
#define LOG_VAR(str, var) std::cout << __LINE__ << ": " << str << var << endl
#define COUT_STRING(stdString) for(string::iterator itCoutLOG = stdString->begin(); itCoutLOG != stdString->end(); itCoutLOG++) cout << *itCoutLOG;cout << endl
#else
#define LOG(str)
#define LOG_VAR(str, var)
#define COUT_STRING(stdString)
#endif //DEBUG_MOD

class errorNote : public string
{
public:
    uint16_t fileNameSize = 16;
    uint16_t line = 0;
    uint16_t counst = 1;

    errorNote(string inputStr, uint16_t inputLine):string(inputStr),line(inputLine)
    {
        LOG("errorNote constructor in.");
        if(this->size() > 16)
        {
            LOG_VAR("this->size() = ", this->size());
            string::iterator it;
            for(it = this->end()-16; it != this->end(); it++)
            {
                if(*it == '\\')
                {
                    LOG("found \\");
                    it++;
                    this->fileNameSize = this->end() - it;
                    LOG_VAR("this->fileNameSize: ",this->fileNameSize);
                    return;
                }
            }
        }else
        {
            LOG_VAR("this->size() = ", this->size());
            string::iterator it;
            for(it = this->end(); it != this->begin(); it--)
            {
                if(*it == '\\')
                {
                    LOG("found \\");
                    it++;
                    this->fileNameSize = this->end() - it;
                    LOG_VAR("this->fileNameSize: ",this->fileNameSize);
                    return;
                }
            }
        }
    }

    static void addNewNote(vector<errorNote>* vNote,errorNote* newNote)
    {
        for(vector<errorNote>::iterator itvNote = vNote->begin(); itvNote != vNote->end(); itvNote++)
        {
            bool conditions_A = itvNote->line == newNote->line; // 行号是否相等

            bool conditions_B = true;                           // 文件名是否相等
            if((itvNote->end() - itvNote->fileNameSize) != 
                (newNote->end() - itvNote->fileNameSize))
                {
                    LOG("fileName长度不相等");
                    conditions_B = false;
                }
            if(conditions_B)
            {
                LOG("fileName长度相等");
                uint16_t fileNameLen = itvNote->fileNameSize;
                string::iterator tmpIt = itvNote->end() - itvNote->fileNameSize;
                string::iterator newIt = newNote->end() - newNote->fileNameSize;

                for(uint16_t i = 0; i < fileNameLen; i++)
                {
                    string::iterator a = tmpIt+i;
                    string::iterator b = newIt+i;
                    if(*a != *b)
                    {
                        LOG_VAR("fileName内容不相等", i);
                        LOG_VAR("itvNote: ", *a);
                        LOG_VAR("newNote: ", *b);
                        conditions_B = false;
                        break;
                    }
                }
            }

            bool conditions_C = true;                           // 路径是否相等
            if(conditions_A && conditions_B)
            {                
                uint16_t pathNameLen = itvNote->size() - itvNote->fileNameSize;
                string::iterator tmpIt = itvNote->begin();
                string::iterator newIt = newNote->begin();
                for(uint16_t i = 0; i < pathNameLen; i++)
                {
                    string::iterator a = tmpIt+i;
                    string::iterator b = newIt+i;
                    if(*a != *b)
                    {
                        LOG("pathName内容不相等");
                        conditions_B = false;
                        break;
                    }
                }
            }else{
                LOG("行号或文件名其一不相等，就没有必要比较路径了");
                conditions_C = false;
            }

            if(conditions_A && conditions_B && !conditions_C)
            {
                LOG("line与fileName相同，pathName不同，counst++");
                itvNote->counst++;
                return;
            }
            else if(conditions_A && conditions_B && conditions_C)
            {
                LOG("line与pathName相同，忽略");
                return;
            }
            LOG("比较下一个Note");
        }
        LOG("没有符合加一或合并条件的，push_back");
        vNote->push_back(*newNote);
    }

    void printInfo()
    {
#ifdef DEBUG_MOD
        LOG("printInfo in");
        for(string::iterator it = this->begin(); it != this->end(); it++) cout << *it;
        cout << endl;
        cout << "this->size() = " << this->size() << endl;
        LOG_VAR("fileName size: ", this->fileNameSize);
        for(string::iterator it = this->end()-this->fileNameSize; it != this->end(); it++) cout << *it;
        cout << ' ' << this->line << endl;
        cout << endl;
#endif //DEBUG_MOD
    }
};

int main()
{
    string inputStr;
    uint16_t inputLine;
    inputStr.reserve(101);
    vector<errorNote> vNote;

    cin >> inputStr;
    cin >> inputLine;
    vNote.emplace_back(inputStr, inputLine);
    (vNote.end()-1)->printInfo();

    for(inputStr; cin >> inputStr;)
    {
        cin >> inputLine;

        errorNote* newNote = new errorNote(inputStr, inputLine);
        inputStr.clear();
        
        errorNote::addNewNote(&vNote, newNote);

        (vNote.end()-1)->printInfo();
    }

vector<errorNote>::iterator itvNotePrint = vNote.end()-8;

    for(vector<errorNote>::iterator itvNotePrint = vNote.end()-8; itvNotePrint != vNote.end(); itvNotePrint++)
    {
        for(string::iterator itCoutLOG = itvNotePrint->end() - itvNotePrint->fileNameSize; itCoutLOG != itvNotePrint->end(); itCoutLOG++) cout << *itCoutLOG;
        cout << " " << itvNotePrint->line << " " << itvNotePrint->counst << endl;
    }

    return 0;
}